<template>
    <XModalButton ref='modalRef' title='选股器' width='1200px' :confirm='submit'>
        <a-button type='primary'>选股器</a-button>
        <template #content>
            <div style="max-height:70vh;overflow-y:auto">
                <Selector type='select' ref='selectorRef' />
            </div>
        </template>
    </XModalButton>
</template>

<script lang='ts' setup>
    import { ref } from '@vue/reactivity'
import { message } from 'ant-design-vue'
    import Selector from '../strategy/stockSelector/index.vue'

    const emit = defineEmits<{
        (e : 'finish', data : any[]) : void
    }>()

    const modalRef = ref()
    const selectorRef = ref()

    function submit(){
        const rows = selectorRef.value.selectedRows
        if(rows.length == 0) {
            message.error('请选择股票')
        }else {
            modalRef.value.close()
            emit('finish', rows)
        }
    }
</script>
